﻿<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="spring" uri="/WEB-INF/lib/spring.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>${table.TableMemo}列表</title>
    <%@include file="../../include/jsAndCss.jsp" %>
    <script type="text/javascript">
	/*数据列表，状态审核，删除，排序*/
var ActionUrl=adminUrl+"${table.TableNameAlias}/";

#foreach($c in $ColumnList)
	#if($c.IsPrimary)
		#set ($primaryKeyAlias=$c.ColumnNameAlias)
	#set ($primaryKey=$c.ColumnName)
	#end
#end
 jQuery(function(){
      SetSelect(Enum.SwitchStatus, "SelectStatus", 1);
    LoadList();
    commonBO.initOperatePower();
 });
 /*数据列表*/
 function LoadList() {
  commonBO.initDataGrid('');
 }

/*刷新页面*/
function reload() {
    commonBO.reload();
}
/*跳转到添加页面*/
function add() {
    location.href = "saveOrUpdate"+admExtension+"?id=0";
}
/*跳转到修改页面*/
function edit() {
    location.href = "saveOrUpdate"+admExtension+"?id=" + commonBO.SelectRowData.rowData.${Utils.ToTitleLower($primaryKeyAlias)};
}
/*跳转到详细页*/
function view() {
    location.href = "view"+admExtension+"?id=" + commonBO.SelectRowData.rowData.${Utils.ToTitleLower($primaryKeyAlias)};
}
/*
 * 启用或禁用
 * */
function audit(status) {
    var dataRows = jQuery("#dataList").datagrid("getSelections");
    var ids = "";
    for (var index in dataRows) {
        if (dataRows[index].status != status)
            ids += "," + dataRows[index].${Utils.ToTitleLower($primaryKeyAlias)};
    }
    commonBO.setAudit(ids, status);
}
/*删除*/
function del() {
    var dataRows = jQuery("#dataList").datagrid("getSelections");
    var ids = "";
    for (var index in dataRows) {
        ids += "," + dataRows[index].${Utils.ToTitleLower($primaryKeyAlias)};
    }
    commonBO.delFromId(ids);
}

/*
 * 排序
 */
function sort() {
	var o = jQuery('#dataList');
	var rowcount = o.datagrid('getRows').length;
	for ( var i = 0; i < rowcount; i++) {
		var editor = o.datagrid('getEditor', {
			index : i,
			field : 'sort'
		});
		if (editor != null) {
			var row = o.datagrid('getRows')[i];
			var id = row.${Utils.ToTitleLower($primaryKeyAlias)};
			var sort = row.sort; // 修改前的排序
			var newSort = editor.target.val();
			if (sort == newSort) {
				o.datagrid('cancelEdit', i);
			} else {
				jQuery.ajax({
					url : ActionUrl + "Sort/" + id + "/" + newSort+ admExtension,
					dataType : "json",
					type : "post",
					async:false,
					success : function(result) {
						if (result.status == "SUCCESS") {
							o.datagrid('endEdit', i);
						} else {
							o.datagrid('cancelEdit', i);
						}
					}
				});
			}
		}
	}
}	
	</script>
</head>
<body class="easyui-layout" fit="false">
<%--查询操作开始--%>
<div style="line-height: 40px; padding-left: 15px; border: 0px;" scroll="no" region="north">
        关键词：
        <input id="txtTitle" type="text"/>
        状态：
        <select id="SelectStatus" panelheight="auto" style="width: 100px;">
            <option value="">==选择==</option>
        </select>
        <a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="LoadList()">查询</a>
</div>
<%--查询操作结束--%>
<%--数据列表开始--%>
<div region="center" title="数据列表">
    <div id="toolbar">
    </div>
    <table id="dataList">
	<thead>
		  #foreach($column in $ColumnList)
		  #set($columnName=${Utils.ToTitleLower(${column.ColumnNameAlias})})
		  #if(${columnName}=="status")
			<th  data-options="field:'${columnName}',width:80,formatter:function(value) {return GetEnumText(Enum.SwitchStatus,value,1);}">
			 <spring:message code="${column.ColumnNameAlias}"/>
			 </th>
		#elseif(${columnName}=="sort")
		 <th  data-options="field:'${columnName}',width:80"  editor="{type:'numberbox',options:{precision:0}}">
			 <spring:message code="${column.ColumnNameAlias}"/>
			 </th>
		  #else
			 <th  data-options="field:'${columnName}',width:80">
			 <spring:message code="${column.ColumnNameAlias}"/>
			 </th>
		  #end
			
          #end
	</thead>
    </table>
</div>
<%--数据列表结束--%>
<%--列表右键开始--%>
<div id="rightKeyMenu" class="easyui-menu" style="width: 120px;">
</div>
<%--列表右键结束--%>
</body>
</html>